RWTH - Mindstorms NXT Toolbox

USGetSnapshotResults

Retrieves up to eight echos (distances) stored inside the US sensor

Contents

Syntax

echos = USGetSnapshotResults(port)

echos = USGetSnapshotResults(port, handle)

Description

echos = USGetSnapshotResults(port) retrieves the echos originating from the ping that was sent out with USMakeSnapshot(port) for the ultrasonic sensor connected to port. In order for this to work, the sensor must have been opened in snapshot mode using OpenUltrasonic(port, 'snapshot').

The last optional argument can be a valid NXT handle. If none is specified, the default handle will be used (call COM_SetDefaultNXT to set one).

The return-vector echos always contains exactly 8 readings for up to 8 echos that were recorded from one single signal. Depending on the structure and reflections, this can only be one valid echo, or a lot of interference. The values are distances, just as you'd expect from GetUltrasonic. The values are sorted in order of appearance, so they should also be sorted with increasing distances.

It is not known how exactly the measurements are to be interpreted!

Please make sure that after calling USGetSnapshotResults, there is a little time period for the sound waves to travel, to be reflected, and be recorded by the sensor. You can estimate this using the speed of sound and the maximum distance you expect to measure.

Note: When the US sensor is opened in snapshot mode, the function GetUltrasonic does not work correctly!

Example

  port = SENSOR_4;
  OpenUltrasonic(port, 'snapshot');
  % send out the ping
  USMakeSnapshot(port);
  % wait some time for the sound to travel
  pause(0.1); % 100ms is probably too much, calculate using c_sound ;-)
  % retrieve all the echos in 1 step
  echos = USGetSnapshotResults(port);
  CloseSensor(SENSOR_4);

See also

OpenUltrasonic, GetUltrasonic, USMakeSnapshot, CloseSensor

Signature